package com.youlv.yl.dao;

import com.youlv.yl.dto.CartItemDto;
import com.youlv.yl.entity.hotel.CartItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author fenghe
 * @since 2022-01-17
 */
@Repository
public interface CartItemDao extends BaseMapper<CartItem> {

    @Select("select * from t_cart_item where cid = #{cid} and gid = #{gid}")
    CartItem selectByCid(@Param("cid") Long cid, @Param("gid") Long gid);

    @Update("update t_cart_item set num = #{num} where id = #{id}")
    int updateNum(@Param("num") int num, @Param("id") Long id);

    /** 批处理*/
    int delBatch(List<Long> ids);

    List<CartItemDto> selectByIds(int[] ids);
}
